using System;
using System.Data;
using digit.Core;

namespace SMS.ServiceManager
{
    public class CodeData
    {
        #region CONSTRUCTORS
        public CodeData(string connectionString)
        {
            this.m_connectionString = connectionString;
        }
        #endregion

        #region ATTRIBUTES
        const string SQL_INSERT = "vn1102_Insert_Code";
        const string SQL_UPDATE = "vn1102_Update_Code";
        const string SQL_DELETE = "vn1102_Delete_Code";
        const string SQL_SELECTONE = "vn1102_Select_Code";
        const string SQL_SELECTALL = "vn1102_SelectAll_Code";
        const string SQL_SEARCH = "vn1102_Search_Code";
        private string m_connectionString;
        #endregion

        #region METHODS
        public bool Insert(object[] values)
        {
            int i = DataAccess.ExecuteStoreProcedure(this.m_connectionString, SQL_INSERT, values);
            return i > 0;
        }

        public bool Update(object[] values)
        {
            int i = DataAccess.ExecuteStoreProcedure(this.m_connectionString, SQL_UPDATE, values);
            return i > 0;
        }

        public bool Delete(object[] values)
        {
            int i = DataAccess.ExecuteStoreProcedure(this.m_connectionString, SQL_DELETE, values);
            return i > 0;
        }

        public DataTable Select(object[] values)
        {
            return DataAccess.FillTable(this.m_connectionString, SQL_SELECTONE, values, true);
        }

        public DataTable SelectAll()
        {
            return DataAccess.FillTable(this.m_connectionString, SQL_SELECTALL, true);
        }

        public bool UpdateStatusErrorSMS(string Status)
        {
            int i = DataAccess.ExecuteStoreProcedure(this.m_connectionString, "vn1102_Update_Code_ErrorStatus", Status);
            return i > 0;
        }

        public DataTable GetAllCodeType()
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_GetAll_CodeType", true);
        }

        public DataTable GetCodeDetail(object[] values)
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_GetCode_Detail", values, true);
        }

        public DataTable GetCode(object[] values)
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_Select_CodeName", values, true);
        }

        public DataTable GetCodeDetailTable(object[] values)
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_GetCode_Detail_ByTypeName", values, true);
        }

        public DataTable GetContent(object[] values)
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_GetCode_Content", values, true);
        }

        public DataTable GetCodeType(string CodeType)
        {
            return DataAccess.FillTable(this.m_connectionString, "vn1102_Get_CodeType", CodeType, true);
        }

        public DataTable GetCodeName(string CodeType)
        {
            return DataAccess.FillTable(this.m_connectionString, "SMS_p_sel_CodeManagerGetCodeName", CodeType, true);
        }

        #endregion

    }
}